<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Item 게시글 작성</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
	$("#item_registerForm").submit(function(){			
		if($(":input[name=itemName]").val()==""){
			alert("상품명을 입력하세요");				
			return false;
			
		}else if($(":input[name=itemPrice]").val()==""){
			alert("가격을 입력하세요");				
			return false;
			
		}else if(isNaN($(":input[name=itemPrice]").val())){
			alert("가격은 숫자로 입력하세요");
			return false;
			
		}
	});
	$(":input[name=cancelBtn]").click(function(){
		if(confirm("상품등록을 취소하시겠습니까?")){
			location.href="${initParam.root}member/home.moja";
		}
	});
});
</script>
</head>
<body>
<div id="mainCss" align="center">
<c:choose>
	<c:when test="${sessionScope.mvo==null}">
		로그인 하신 후 사용 가능합니다.
	</c:when>
	
<c:otherwise>
<form id="item_registerForm" action="${initParam.root}item/auth_register.moja"  enctype="multipart/form-data" method="post">
<table border="1" bordercolor="#D2D2D2">
<tr>
<td colspan="2">
<div align="center">
<font size="5px" color="#000000">상 품 등 록</font><img src="${initParam.root }img/pen1.jpg">
</div>
</td>
</tr>
<tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000" size="2px"><b>작성자</b></font></td>
<td><input type="text" readonly="readonly" name="memberId" value="${sessionScope.mvo.memberId }"></td>
</tr>
<tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"size="2px"><b>상품명</b></font></td>
<td><input type="text" name="itemName" size="40px"></td>
</tr>
<tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"size="2px"><b>상품가격</b></font></td>
<td><input type="text" name="itemPrice"><font color="#000000"><b> 원</b></font></td></tr>
 <tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"size="2px"><b>파일 업로드</b></font></td><td><input type="file" name="uploadFile"><br>
</tr>
 
<tr>
<td colspan="2"><font color="#000000" size="3px"><b>상세설명</b></font><br>
<textarea cols="90px" rows="5" name="itemInfo" id="content"></textarea>
</td>
<tr>
<td colspan="2" bgcolor="#D2D2D2"><font color="#000000" size="3px"><b>카테고리(여러개 선택가능)</b></font></td>
</tr>
<tr>
<td colspan="2">
<c:forEach items="${requestScope.map }" var="map">
	${map.key } : <br>
	<c:forEach items="${map.value }" var="list">
		<input type="checkbox" name="${map.key }" value="${list }">${list }
	</c:forEach>
	<br>
</c:forEach>

</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" value="작성완료">
<input type="button" name = "cancelBtn" value="작성취소">
</div>
</td>
</tr>
</table>
</form>
</c:otherwise>
</c:choose>
</div>
</body>
</html>